//
//  TKL_HomeViewModel.m
//  TKL_EnPro
//
//  Created by 雅恩三河科技 on 2018/12/7.
//  Copyright © 2018年 MrZhang. All rights reserved.
//

#import "TKL_HomeViewModel.h"

@implementation TKL_HomeBeauModel
@end
@implementation TKL_HomeCityModel
@end
@implementation TKL_HomeAdModel
@end
@interface TKL_HomeViewModel ()

@end

@implementation TKL_HomeViewModel

-(NSMutableArray *)beautyArr
{
    if (!_beautyArr) {
        _beautyArr=[NSMutableArray new];
    }
    return _beautyArr;
}
-(NSMutableArray *)datas
{
    if (!_datas) {
        _datas=[NSMutableArray new];
    }
    return _datas;
}
-(NSMutableArray *)itemArr
{
    if (!_itemArr) {
        _itemArr=[NSMutableArray new];
    }
    return _itemArr;
}
#pragma mark - method
-(void)requestBeautyData:(NSMutableDictionary *)para
{
    @WeakSelf;
    [[InterfaceManager shareInterface] requetInterface:@"get_home_btom" withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        if (infoModel.errorCode ==0)
        {
            NSMutableArray* arr=[NSMutableArray new];
            NSArray* myArr=(NSArray*)info;
            for (NSDictionary* dic in myArr)
            {
                TKL_HomeBeauModel* model=[TKL_HomeBeauModel yy_modelWithJSON:dic];
                [arr addObject:model];
            }
            [selfp setBeautyArr:arr];
        }else
        {
            [FTIndicator showErrorWithMessage:infoModel.errorMsg];
        }
    }];
}
-(void)requestCityData:(NSMutableDictionary *)para
{
    @WeakSelf;
    [[InterfaceManager shareInterface] requetInterface:@"get_home_tripcity" withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        if (infoModel.errorCode ==0)
        {
            NSMutableArray* arr=[NSMutableArray new];
            NSArray* myArr=(NSArray*)info;
            for (NSDictionary* dic in myArr)
            {
                TKL_HomeCityModel* model=[TKL_HomeCityModel yy_modelWithJSON:dic];
                [arr addObject:model];
            }
            [selfp setDatas:arr];
        }else
        {
            [FTIndicator showErrorWithMessage:infoModel.errorMsg];
        }
    }];
}
-(void)requestAdData:(NSMutableDictionary*)para
{
    @WeakSelf;
    [[InterfaceManager shareInterface] requetInterface:@"get_home_ad" withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        if (infoModel.errorCode ==0)
        {
            NSMutableArray* arr=[NSMutableArray new];
            NSArray* myArr=(NSArray*)info;
            
            for (NSDictionary* dic in myArr)
            {
                TKL_HomeAdModel* model=[TKL_HomeAdModel yy_modelWithJSON:dic];
                [arr addObject:model];
            }
            [selfp setItemArr:arr];
        }else
        {
            [FTIndicator showErrorWithMessage:infoModel.errorMsg];
        }
    }];;
}
-(void)requestPass
{
    @WeakSelf;
//    NSURL *url = [NSURL URLWithString:@"http://47.96.127.184:12000"];
//    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
//    [request setHTTPMethod:@"POST"];
//    [NSURLConnection sendAsynchronousRequest:request queue:NSOperationQueue.mainQueue completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
//        NSString *res = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
//        if (![WFFunctions WFStrCheckEmpty:res])
//        {
//            NSDictionary *dic = [WFFunctions WFDictionaryWithJsonString:res];
//            NSLog(@"------%@",dic);
//            [self setSouceDic:[[NSMutableDictionary alloc] initWithDictionary:dic]];
//        }
//
//
//
//    }];
}
-(instancetype)init
{
    if (self = [super init]) {
        
    }
    return self;
}
#pragma mark - delegate
@end
